package com.cqupt.controller;

import com.cqupt.model.pojo.Sentence;
import com.cqupt.model.vo.Result;
import com.cqupt.model.vo.ResultCodeEnum;
import com.cqupt.model.vo.SentenceVO;
import com.cqupt.service.SentenceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/sentence")
@Tag(name = "获取名言警句模块")
public class SentenceController {

    @Resource
    private SentenceService sentenceService;

    @GetMapping("/sentence")
    @Operation(summary = "获取名言警句")
    public Result getSentence() {
        SentenceVO res = sentenceService.getSentence();
        return Result.build(res, ResultCodeEnum.SUCCESS);
    }

    @GetMapping("/getChange")
    @Operation(summary = "更换名言警句（查看有哪些）")
    public Result getChange() {
        List<Sentence> res = sentenceService.getChange();
        return Result.build(res, ResultCodeEnum.SUCCESS);
    }

    @GetMapping("/change")
    @Operation(summary = "更换名言警句（确认更换）")
    public Result change(@RequestParam Integer id) {
        sentenceService.change(id);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }

}
